package com.leyou.item.client;

import com.leyou.common.dto.PageDTO;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@FeignClient("ly-service")
public interface ItemClient {

    @GetMapping("/goods/spu/page")
    PageDTO<SpuDTO> queryPage(
            @RequestParam(value = "page",defaultValue = "1")Integer page,
            @RequestParam(value = "rows",defaultValue = "5")Integer rows,
            @RequestParam(value = "brandId",required = false)Long brandId,
            @RequestParam(value = "categoryId",required = false)Long categoryId,
            @RequestParam(value = "id",required = false)Long id,
            @RequestParam(value = "saleable",required = false)Boolean saleable
    );

    @GetMapping("/goods/sku/of/spu")
    List<SkuDTO> querySkuBySpuId(@RequestParam("id")Long id);

    @GetMapping("/goods/spec/value")
    List<SpecParamDTO> querySpecValues(@RequestParam("id")Long id
            , @RequestParam(value = "searching",required = false)Boolean searching);

    @GetMapping("/brand/list")
    List<BrandDTO> queryBrandByIds(@RequestParam("ids")List<Long> ids);

    @GetMapping("/category/list")
    List<CategoryDTO> queryCategoryByIds(@RequestParam("ids") List<Long> ids);

    @GetMapping("/goods/{id}")
    SpuDTO queryGoodsById(@PathVariable("id")Long id);

    @GetMapping("/goods/spu/{id}")
    SpuDTO querySpuById(@PathVariable("id")Long id);

    @GetMapping("/goods/spu/detail")
    SpuDetailDTO querySpuDetailById(@RequestParam("id")Long id);

    @GetMapping("/brand/{id}")
    BrandDTO queryBrandById(@PathVariable("id")Long id);

    @GetMapping("/spec/list")
    List<SpecGroupDTO> querySpec(@RequestParam("id")Long categoryId);

    @GetMapping("/goods/sku/list")
    List<SkuDTO> querySkuByIds(@RequestParam("ids")List<Long> ids);

    @PutMapping("/goods/stock/minus")
    Void reduceSkuStock(@RequestBody Map<Long,Integer> map);

    @PutMapping("/goods/stock/plus")
    Void plusSkuStock(@RequestBody Map<Long,Integer> map);
}
